<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */
namespace App\Controller;
use App\Model\Manager;
use Hyperf\Di\Annotation\Inject;
use Qbhy\HyperfAuth\Annotation\Auth;
use Qbhy\HyperfAuth\AuthManager;
use App\Constants\ReturnCode;
use App\Helper\Log;
use Hyperf\DbConnection\Db;
use App\Service\AccountService;
use Throwable;

class IndexController extends AbstractController
{
    #[Inject]
    protected AuthManager $auth;
    #[Inject]
    protected AccountService $account;
    public function index()
    {
         // 获取指定用户对象，不存在则插入并返回用户对象
        //  $user = Manager::query()->find(1);
        //  $token = $this->auth->login($user,['xxx'=>111,'bbb'=>222]);
        //  $data = [
        //     'token'=>$token
        //  ];
        //  Db::table('user')->where('id', '>', 1)->lockForUpdate()->get();

         //Db::table('users')->where('votes', '>', 100)->lockForUpdate()->get();
        //  $res = $this->account->addMoney(1,1,'rebate','cs0002');
        $res = ['name'=>'小王','action'=>'上学'];
        return $this->fmt_response(ReturnCode::deal_succ,'操作成功',$res);
    }
}
